﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using MallInteractiveMap.Common;
using MallInteractiveMap.DTO;
using MallInteractiveMap.ServerDataHandler;

namespace MallInteractiveMap.ClientDataHandler
{
    public class ClientData
    {
        public static string CONNECTIONSTRING
        {
            set { ServerDatabaseHandler.CONNECTIONSTRING = value; }
        }

        public static DataSet GetData(string tableName, QueryParamList pParam, ref string pErrString)
        {
            try
            {
                return new ServerDatabaseHandler().GetData(tableName, pParam, ref pErrString);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// Executes a store procedure
        /// </summary>
        /// <param name="pParam">paramter for the SP</param>
        /// <param name="spName">Name of the SP</param>
        /// <param name="pErrString"></param>
        /// <returns></returns>
        public static bool SetData(QueryParamList pParam, string spName, ref string pErrString)
        {
            try
            {
                new ServerDatabaseHandler().SetData(pParam, spName, ref pErrString);
            }
            catch
            {
                return false;
            }
            return true;
        }
        public static List<DTOUser> GetUsers(QueryParamList queryParamList, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().GetUsers(queryParamList, ref error);
            }
            catch
            {
                //ToDo
            }
            return null;
        }
        public static bool IsValidUser(QueryParamList queryParamList, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().IsValidUser(queryParamList, ref error);
            }
            catch
            {
                //ToDo
            }
            return false;
        }

        public static void ExecuteQuery(string query, QueryParamList queryParamList, ref string pError)
        {
            try
            {
                new ServerDatabaseHandler().ExecuteQuery(query, queryParamList, ref pError);
            }
            catch
            {
                //ToDo
            }
        }

        public static List<DTOMall> GetMall(QueryParamList queryParamList, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().GetMalls(queryParamList, ref error);
            }
            catch
            {
                //ToDo
            }
            return null;
        }

        public static List<DTOCategory> GetCategory(QueryParamList queryParamList, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().GetCategorys(queryParamList, ref error);
            }
            catch
            {
                //ToDo
            }
            return null;
        }

        public static List<DTOMap> GetMap(QueryParamList queryParamList, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().GetMaps(queryParamList, ref error);
            }
            catch
            {
                //ToDo
            }
            return null;
        }

        public static List<DTOFloor> GetFloor(QueryParamList queryParamList, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().GetFloors(queryParamList, ref error);
            }
            catch
            {
                //ToDo
            }
            return null;
        }

        public static List<DTOShop> GetShop(QueryParamList queryParamList, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().GetShops(queryParamList, ref error);
            }
            catch
            {
                //ToDo
            }
            return null;
        }

        public static List<DTOShopPhotos> GetShopPhoto(QueryParamList queryParamList, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().GetShopPhotos(queryParamList, ref error);
            }
            catch
            {
                //ToDo
            }
            return null;
        }
        public static List<DTOShopPhotos> GetShopPhoto(string shopNo, int floorId, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().GetShopPhotos(shopNo, floorId, ref error);
            }
            catch
            {
                //ToDo
            }
            return null;
        }

        public static bool SaveShop(DTOShop shop, ref string error)
        {
            try
            {
                return new ServerDatabaseHandler().SaveShop(shop, ref error);
            }
            catch
            {
                //ToDo
            }
            return true;
        }

        public static List<DTOShop> SearchShops(string query)
        {
            try
            {
                return new ServerDatabaseHandler().SearchShops(query);
            }
            catch
            {
                //ToDo
            }
            return null;
        }

        public static int GetFloorId()
        {
            try
            {
                return new ServerDatabaseHandler().GetFloorId();
            }
            catch
            {
                //ToDo
            }
            return -1;
        }

        public static bool IsShopAvailable(int categoryId)
        {
            try
            {
                return new ServerDatabaseHandler().IsShopAvailable(categoryId);
            }
            catch
            {
                //ToDo
            }
            return false;
        }
    }
}
